<template>
    <div class="drawer_list">
        <div class="drawer_header">
            <div class="button" v-if="!shortcutstate.addshow" @click="shortcutstore.openaddShortcut()">新增</div>
            <div class="button" v-if="shortcutstate.addshow" @click="shortcutstore.closeaddShortcut()">返回</div>
        </div>

        <div class="list_body">
            <template v-if="!shortcutstate.addshow">
                <el-table :data="shortcutstate.shortcutList" v-loading="shortcutstate.listloading" style="height: 100%"
                    max-height="100%" height="100%">
                    <el-table-column prop="name" label="名称" />
                    <el-table-column prop="keyPressed" label="快捷方式" />
                    
                    <el-table-column prop="address" label="操作" width="100">
                        <template #default="scope">
                            <div style="display: flex;">
                                <div style="cursor: pointer;color: #ff6002;" @click="shortcutstore.editShortcut(scope.row)">编辑</div>
                                <div style="margin-left: 12px;cursor: pointer;color: red;" @click="shortcutstore.deleteShortcut(scope.row)">删除</div>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
            </template>
            <template v-if="shortcutstate.addshow">
                <AddShortcut />
            </template>

        </div>

        <UserDialog v-if="shortcutstate.userdialog.show" v-model="shortcutstate.userdialog.show"/>
    </div>
</template>

<script setup>
import AddShortcut from "./AddShortcut.vue";
import UserDialog from "./UserDialog.vue";
const { shortcutstore, shortcutstate } = inject('shortcutSell')
</script>

<style lang="scss" scoped>
.drawer_list {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    
}

.drawer_header {
    display: flex;
    justify-content: space-between;

    .text {
        font-size: 16px;
        font-weight: bold;
    }

    .button {
        width: 52px;
        height: 28px;
        padding: 4px 12px;
        background-color: #ff6002;
        color: #fff;
        cursor: pointer;
    }
}

.list_body {
    flex: 1;
    padding-top: 12px;
    // background-color: red;
}
</style>